var Action = require("../apiaction");
var Utility = require("../Utility/utility.js");
exports.userAPI = function(router){

    //获取短信验证码列表
    router.all('/user/getuserlist',function(req,res){

        var params ={mobile: req.param("mobile")};
        params = Utility.get_list_page_size_param(req,params);

        Action.send(req, res,"/user/getuserlist",params,function(res,data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/workerCheckin/getListPaging', function (req, res) {

        var params = {worker_id: req.param("worker_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/workerCheckin/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //轮播图

    //列表获取
    router.all('/user/getCaroselList', function (req, res) {

        var params = {type:req.param("type")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/getCaroselList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/user/addCarosel', function (req, res) {

        var params = {pic_url: req.param("pic_url"),link_url: req.param("link_url"),title: req.param("title"),type:req.param("type")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/addCarosel", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //修改

    //更新
    router.all('/user/updateCarosel', function (req, res) {

        var params = {type:req.param("type"),pic_url: req.param("pic_url"),link_url: req.param("link_url"),title: req.param("title"),obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/updateCarosel", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/user/deleteCarosel', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/deleteCarosel", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //用户案例

    //添加
    router.all('/user/addUserCase', function (req, res) {

        var params = {name: req.param("name"),type_id: req.param("type_id"),start_day: req.param("start_day"),end_day: req.param("end_day"),picurl: req.param("picurl"),fee: req.param("fee"),comment: req.param("comment")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/addUserCase", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/user/getUserCaseList', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/getUserCaseList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/user/updateUserCase', function (req, res) {

        var params = {name: req.param("name"),obj_id: req.param("obj_id"),type_id: req.param("type_id"),start_day: req.param("start_day"),end_day: req.param("end_day"),picurl: req.param("picurl"),fee: req.param("fee"),comment: req.param("comment")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/updateUserCase", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/user/deleteUserCase', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/deleteUserCase", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/user/getUserCaseTypeList', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/getUserCaseTypeList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //列表获取
    router.all('/user/getUserCaseTaskList', function (req, res) {

        var params = {case_id: req.param("case_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/getUserCaseTaskList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/user/addUseCaseTask', function (req, res) {


        var construction_piclist = "";

        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct1");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct2");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct3");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct4");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct5");
        construction_piclist = Utility.mergeParam(req,construction_piclist,"construct6");


        var testpiclist = "";

        testpiclist = Utility.mergeParam(req,testpiclist,"testpic1");
        testpiclist = Utility.mergeParam(req,testpiclist,"testpic2");
        testpiclist = Utility.mergeParam(req,testpiclist,"testpic3");
        testpiclist = Utility.mergeParam(req,testpiclist,"testpic4");
        testpiclist = Utility.mergeParam(req,testpiclist,"testpic5");
        testpiclist = Utility.mergeParam(req,testpiclist,"testpic6");


        var params = {case_id: req.param("case_id"),name: req.param("name"),worker_name: req.param("worker_name"),days: req.param("days"),
            material: req.param("material"),piclist: construction_piclist,
            testor_name: req.param("testor_name"),testpiclist: testpiclist,test_content: req.param("test_content"),
        };
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/addUseCaseTask", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/user/updateUserCaseTask', function (req, res) {


        var params = {case_id: req.param("case_id"),name: req.param("name"),worker_name: req.param("worker_name"),days: req.param("days"),
            material: req.param("material"),piclist: req.param("piclist"),obj_id: req.param("obj_id"),
        };

        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/updateUserCaseTask", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/user/deleteUserCaseTask', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/user/deleteUserCaseTask", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //效果图种类
    //列表获取
    router.all('/ucPreivew/getListPaging', function (req, res) {

        var params = {};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreivew/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/ucPreivew/add', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark"),picurl: req.param("picurl")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreivew/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/ucPreivew/delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreivew/delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/ucPreivew/update', function (req, res) {

        var params = {name: req.param("name"),remark: req.param("remark"),picurl: req.param("picurl"),obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreivew/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //效果图列表
    //列表获取
    router.all('/ucPreviewList/getListPaging', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreviewList/getListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //添加
    router.all('/ucPreviewList/add', function (req, res) {

        var design_piclist = "";

        design_piclist = Utility.mergeParam(req,design_piclist,"design1");
        design_piclist = Utility.mergeParam(req,design_piclist,"design2");
        design_piclist = Utility.mergeParam(req,design_piclist,"design3");
        design_piclist = Utility.mergeParam(req,design_piclist,"design4");
        design_piclist = Utility.mergeParam(req,design_piclist,"design5");
        design_piclist = Utility.mergeParam(req,design_piclist,"design6");

        var params = {name: req.param("name"),pic_url:design_piclist,view_count: req.param("view_count") ,order_count: req.param("order_count"),worker_id: req.param("worker_id"),type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreviewList/add", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //删除
    router.all('/ucPreviewList/delete', function (req, res) {

        var params = {obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreviewList/delete", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //更新
    router.all('/ucPreviewList/update', function (req, res) {

        var design_piclist = "";

        design_piclist = Utility.mergeParam(req,design_piclist,"design1");
        design_piclist = Utility.mergeParam(req,design_piclist,"design2");
        design_piclist = Utility.mergeParam(req,design_piclist,"design3");
        design_piclist = Utility.mergeParam(req,design_piclist,"design4");
        design_piclist = Utility.mergeParam(req,design_piclist,"design5");
        design_piclist = Utility.mergeParam(req,design_piclist,"design6");

        var params = {name: req.param("name"),pic_url: design_piclist ,view_count: req.param("view_count") ,order_count: req.param("order_count") ,worker_id: req.param("worker_id"),type_id: req.param("type_id"),obj_id: req.param("obj_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/ucPreviewList/update", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //设计师列表获取
    router.all('/worker/getDesignerListPaging', function (req, res) {

        var params = {type_id: req.param("type_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/worker/getDesignerListPaging", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });


    //用户提现列表获取
    router.all('/UserAmount/getList', function (req, res) {

        var params = {mobile: req.param("mobile"),status:req.param("status")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/UserAmount/getList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });

    //拒绝
    router.all('/UserAmount/denyRequest', function (req, res) {

        var params = {reason: req.param("reason"), request_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/UserAmount/denyRequest", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //同意
    router.all('/UserAmount/acceptRequest', function (req, res) {

        var params = {reason: req.param("reason"), request_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/UserAmount/acceptRequest", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //操作日志列表获取
    router.all('/UserAmount/getLogList', function (req, res) {

        var params = {request_id: req.param("request_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/UserAmount/getLogList", params, function (res, data) {
            res.status(200).json(JSON.parse(data));
        });
    });
    //获取现金流水
    router.all('/UserAmount/getBankCashList', function (req, res) {

        var params = {user_id: req.param("user_id")};
        params = Utility.get_list_page_size_param(req, params);

        Action.send(req, res, "/UserAmount/getBankCashList", params, function (res, data) {

            console.log(data);
            res.status(200).json(JSON.parse(data));
        });
    });












}
